﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string sqlstr = "server = .;uid = sa; pwd = 123456; database = adonet";
            SqlConnection sqlConnection = new SqlConnection(sqlstr);
            string cmd =string.Format("select * from Student") ;
            SqlCommand sqlCommand = new SqlCommand(cmd,sqlConnection);
            sqlConnection.Open();
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
            

            while (sqlDataReader.Read())
            {
                Console.WriteLine("{0}\t{1}", sqlDataReader["Name"], sqlDataReader["Age"]);
            }
            sqlConnection.Close();




        }
    }
}
